// The difference of compound type between c++ and c

#include <iostream>
#include <cstring>

using namespace std;


void TestStruct( ) {
	struct Student {
		int age;
		char name[256];
		void getinfo( ) { 
			cout << "name : " << name << endl;
			cout << "age : " << age << endl;
		}
	};

	/* struct */Student s;

	s.age = 22;
	strcpy( s.name, "zhangfei" );
	cout << "name : " << s.name << endl;
	cout << "age : " << s.age << endl;
	s.getinfo( );
}

void TestUnion( ) { 
	union { 
		int i;
		char c[4];
	};
	/* union */  //A a;
	
	i = 0x12345678;
	cout << hex<< (int) c[0] << ' ' << (int)c[1] << ' ' << (int)c[2] << ' ' << (int)c[3] << endl;
}

void TestEnum( ) {
	enum Color { red, green, blue };
	/* enum */ Color c = red;	 //= 0; 	err
	cout << "c = " << c << endl;
}

void TestBool( ) {
	// The compound type can not be turn into bool type
	bool a = true;
	bool b = false;
	bool c = "";
	cout << "a = " << a << ' ' << "b = " << b << endl;
	cout << "c = " << c << endl;
}

int main( void ){
	TestStruct( );
	TestUnion( );	
	TestEnum( );
	TestBool( );

	return 0;
}




